package data_structure;

public class leetcode_0404 {
    public int sumOfLeftLeaves(TreeNode root) {
        int [] sum=new int[1];
        sum[0]=0;
        if(root==null) return 0;
        sum(sum,root);
        return sum[0];
    }
    public void sum(int [] sum,TreeNode node){
        if(node.left!=null&&node.left.left==null&&node.left.right==null){
            sum[0]+=node.left.val;
        }
        else if(node.left!=null){
            sum(sum,node.left);
        }
        if(node.right!=null) sum(sum,node.right);
    }
}
